/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package clases;

import Principal.frmPrincipal;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author Juan
 */
public class SVServidor extends Thread{
    int por;
    private JFrame ventana;
    ServerSocket ss=null;
    Socket s;

    public SVServidor(int por) {
        this.por = por;
    }
    
    public void run(){
        try {
            ss=new ServerSocket(por);
            while(true){
                s=ss.accept();
                SVGestorConexiones.getInstancia().conectaNuevo(new SVConexion(s));
            }
        } catch (Exception e2) {
            JOptionPane.showMessageDialog(ventana, "Error al Abrir el Puerto");
        }
        try {
            ss.close();
        } catch (Exception e) {
        }
    }
    
    public static void main(String[] args) {
        SVServidor servidor = new SVServidor(7878);
        servidor.start();
        frmPrincipal principal = new frmPrincipal();
        principal.setVisible(true);
            
    }
}
